<template>
  <div class='order-detail'>
    <DetailHead @doPrint="doPrint" @fillInCourier="fillInCourier" @fillPic="fillPic" @doDel="doDel" @doCancel="doCancel" />
    <DetailBody :printStart="printStart" :data="detailData" />
    <CourierModel v-if="$store.state.dias.courier.show" :id="id" @flash="init" />
    <CourierPic v-if="$store.state.dias.courierPic.show" :id="id" @flash="init" />
  </div>
</template>
<script>
import DetailHead from '../specify/detail/head.vue'
import DetailBody from './body.vue'
import CourierModel from './dia/courier'
import CourierPic from './dia/courierPic'
import MixDetail from '@/mix/mixDetail.js'
export default {
  components: {DetailHead,DetailBody,CourierModel,CourierPic},
  name: "",
  data() {
    return {
      printStart:false,
      detailData:{
        data:[],
        info:{},
        receiver:{},
      },
    };
  },
  methods: {
    doPrint(){
      this.printStart=true
      setTimeout(()=>{
        this.printStart=false
      },100)
    },
    /**
     * @name 填写订单号
     */
    fillInCourier(){
        if(this.detailData.receiver.logistics == null){
            this.$store.state.dias.courier.show=true
        }else{
            this.$store.state.dias.courier.show=false
        }
    },

    fillPic(){
        if(this.detailData.receiver.logistics == null){
            this.$store.state.dias.courierPic.show=true
        }else{
            this.$store.state.dias.courierPic.show=false
        }
    },

    doDel(){
      _g.apiPost(this.urls.del,{id:this.id}).then(res=>{
        _g.toMessage(res)
        if(res.status===0)this.$router.go(-1)
      })
    },
    doCancel(){
      _g.apiPost(this.urls.cancel,{id:this.id}).then(res=>{
        _g.toMessage(res)
        if(res.status===0)this.$router.go(-1)
      })
    },

    init(){
      this.getDetail()
    }
  },
  created() {
    this.init()
  },
  mixins:[MixDetail],
};
</script>
<style lang="scss" scoped>
.order-detail {
  padding-bottom: 150px;
}
</style>